import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

/**
 * Note: sub-menu only appear when route children.length >= 1
 * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 *
 * hidden: true                   if set true, item will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu
 *                                if not set alwaysShow, when item has more than one children route,
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noRedirect           if set noRedirect will no redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    roles: ['admin','editor']    control the page roles (you can set multiple roles)
    title: 'title'               the name show in sidebar and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar
    breadcrumb: false            if set false, the item will hidden in breadcrumb(default is true)
    activeMenu: '/example/list'  if set path, the sidebar will highlight the path you set
  }
 */

/**
 * constantRoutes
 * a base page that does not have permission requirements
 * all roles can be accessed
 */
export const constantRoutes = [
  
    {
        path: '/404',
        component: () =>
            import('@/views/404'),
        hidden: true
    },

    {
        path: '/',
        component: Layout,
        redirect: '/dashboard',
        children: [{
            path: 'dashboard',
            name: 'Dashboard',
            component: () =>
                import('@/pages/home/index'),
            meta: { title: '首页', icon: 'dashboard' }
        }]
    },

    {
        path:'/history_data',
        component:Layout,
        children:[
            {
                path: 'index',
                name: 'history_data',
                component: () =>
                    import ('@/pages/history_data/index'),
                meta: { title: '疫情历史数据', icon: 'example' }
            }

            
        ]
    },
    {
        path: '/nearbyHistory_data',
        component: Layout,
      
        children: [{
            path: 'index',
            name: 'nearbyHistory_data',
            component: () =>
                import ('@/pages/nearbyHistory_data/index'),
            meta: { title: '附近历史轨迹', icon: 'eye-open' }
        }]
    },
    {
        path: '/Distribution-patients_data',
        component: Layout,
      
        children: [{
            path: 'index',
            name: 'Distribution-patients_data',
            component: () =>
                import ('@/pages/Distribution-patients_data/index'),
            meta: { title: '患病人群分布', icon: 'eye' }
        }]
    },
    {
        path: '/generalPopulation_data',
        component: Layout,
      
        children: [{
            path: 'index',
            name: 'generalPopulation_data',
            component: () =>
                import ('@/pages/generalPopulation_data/index'),
            meta: { title: '正常人群分布', icon: 'form' }
        }]
    },
    {
        path: '/vehicle_distribution',
        component: Layout,
        children: [{
            path: 'index',
            name: 'vehicle_distribution',
            component: () =>
                import('@/pages/vehicle_distribution/index'),
            meta: { title: '武汉车辆分布', icon: 'link' }
        }]
    },



    {
        path: '/growth_rate',
        component: Layout,
        meta: { title: '增长率', icon: 'example' },
        children: [{
            path: 'index',
            name: 'growth_rate',
            component: () =>
                import('@/pages/growth_rate/index'),
            meta: { title: '全国增长率', icon: 'nested' }
        },
        {
            path: 'two',
            name: 'growth_two',
            component: () =>
                import('@/pages/growth_rate/two'),
            meta: { title: '其他增长率', icon: 'password' }
        }]
    },

    {
        path: '/publicity_video',
        component: Layout,
        children: [{
            path: 'index',
            name: 'publicity_video',
            component: () =>
                import('@/pages/publicity_video/index'),
            meta: { title: '宣传视频', icon: 'table' }
        }]
    },
    {
        path: '/epidemicNews_data',
        component: Layout,
        children: [{
            path: 'index',
            name: 'epidemicNews_data',
            component: () =>
                import('@/pages/epidemicNews_data/index'),
            meta: { title: '疫情新闻', icon: 'tree' }
        }]
    },
    {
        path: '/epidemicRisk_areas',
        component: Layout,
        children: [{
            path: 'index',
            name: 'epidemicRisk_areas',
            component: () =>
                import('@/pages/epidemicRisk_areas/index'),
            meta: { title: '疫情风险地区', icon: 'user' }
        }]
    },
    {
        path: '/risk_areas',
        component: Layout,
        children: [{
            path: 'index',
            name: 'risk_areas',
            component: () =>
                import ('@/pages/risk_areas/index'),
            meta: { title: '中高险地区最新排名', icon: 'dashboard' }
        }]
    },
 
    
   
    
    { path: '*', redirect: '/404', hidden: true }
]

const createRouter = () => new Router({
    // mode: 'history', // require service support
    scrollBehavior: () => ({ y: 0 }),
    routes: constantRoutes
})

const router = createRouter()
export function resetRouter() {
    const newRouter = createRouter()
    router.matcher = newRouter.matcher // reset router
}

export default router